<?
$poll_name = $this->poll_name;
$answers = $this->answers;
if ($this->sum_count){
    $sum_count = $this->sum_count;
}
?>
<style type="text/css">

    #back {
        background: url("/images/forpoll.jpg") repeat-x;
        height: 23px;
        width: 255px;
        -webkit-border-radius: 6px;
       -moz-border-radius: 6px;
       border-radius: 6px;


    }
    #top {
        background-color: #0460D9;
        background-image: -moz-linear-gradient(center top , #0BC2FB, #0460D9);
        float: left;
        padding-bottom: 23px;
        padding-top: 0;

    }
    #percent {
        color: gray;
        text-shadow: 5px;

    }
</style>

<script type="text/javascript" >
    $().ready(function() {
       initPoll();
    });
</script>


<?php if (!$this->sum_count):?>

<div><?=$poll_name;?></div>
<form id="form_poll">
    <? foreach ($answers as $answer): ?>
    <input id = "<?= $answer['id'] ?>" type="radio" name="answer" value="<?= $answer['name'] ?>" /> <?= $answer['name'] ?><br />
    <? endforeach;?>
    <input type="submit" class="btn" id="submit" value="Submit" style="margin-top:10px">
</form>
<div id="results"></div>
<?php else: ?>

<div><?=$poll_name;?></div>
<? foreach ($answers as $answer): ?>
    <div id="results">
        <div><?= $answer['name'] ?></div>
        <div id="back">

            <div style="width: 255px;">
                <div id="top" style="width: <?= ( round((255*$answer['votesCount'])/$sum_count)) ?>px;"></div>
            </div>
            <div id="percent" ><?= round((100*$answer['votesCount'])/$sum_count) ?>% (<?=$answer['votesCount'];?>)
            </div>
        </div>
    </div>
    <br>
    <? endforeach;?>
<p>Total: <?=$sum_count?></p>
<?php endif; ?>





